from gxl_ai_utils.utils import utils_file

time_now = utils_file.do_get_now_time()
input_shards_path, replace_dir, dataname, remote_root_dir, thread_num = utils_file.do_get_commandline_param(5, ["input_shards_path", "replace_dir","dataname", "remote_root_dir", "thread_num"])
utils_file.logging_info("Start uploading shards to remote server，start time: {}")
utils_file.logging_info(f"input_shards_path: {input_shards_path}")
utils_file.logging_info(f"replace_dir: {replace_dir}")
utils_file.logging_info(f"dataname: {dataname}")
utils_file.logging_info(f"remote_root_dir: {remote_root_dir}")
utils_file.logging_info(f"thread_num: {thread_num}")

fake_file = utils_file.do_replace_str_for_file_and_return_new_file(input_shards_path,replace_dir,f"{remote_root_dir}/{dataname}")
utils_file.do_sync_copy_file_upload(fake_file,f"{remote_root_dir}/{dataname}/shards_list.txt",
                                    username="root",
                                    password="Fy!mATB@QE",
                                    remote_host="139.210.101.41",
                                    )
utils_file.do_sync_files_upload_data_multi_thread(
    file_list_path=input_shards_path,
    username="root",
    password="Fy!mATB@QE",
    remote_host="139.210.101.41",
    remote_dir=f"{remote_root_dir}/{dataname}",
    num_thread=int(thread_num), # 30h
)
esl_time = utils_file.do_get_elapsed_time(time_now)
utils_file.logging_info(f"End uploading shards to remote server，Total time: {esl_time} s")